package Boundry.GenericTools;

import java.awt.EventQueue;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

public class TableListPanel extends ViewDataPanel 
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//private JTable table;
	private int returned_value;
	private DefaultTableModel model;
	protected JPanel tablepanel;
	private JScrollPane scrollPane;
	private GenericTabel table;
	
	public TableListPanel(int Width,int Height,String tableName) 
	{
		returned_value=-1;

		
		tablepanel  = new JPanel(new GridLayout(1,1));
		tablepanel.setBounds(91, 68, Width, Height);
		mainPanel.add(tablepanel);
		table = new GenericTabel(Width-10, Height-25, tableName);
		tablepanel.add(table);
	}
	
	public void buildTabel(String[] columnNames, String[][] tableData)
	{   
		table.buildTabel(columnNames,tableData);
	}
	
	public void addRow(String[] row)
	{
		table.addRow(row);	
	}
	
	public void addColumn(String colName)
	{
		table.addColumn(colName);
	}
	
	public void removeRow(int rowLineNumber)
	{
		table.removeRow(rowLineNumber);
	}
	
	public void removeAllRows()
	{
		table.removeAllRows();
	}
	
    public boolean isChosen() 
    {
    	return table.isChosen();
    }
    
    public int getChosen()
    {
    	 return table.getChosen();
    }
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JFrame frame = new JFrame();
					frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
					frame.setBounds(100, 100, 550, 500);
					TableListPanel b = new TableListPanel(50,50,"Table naem");
					frame.getContentPane().add(b);
					frame.setVisible(true);
					
			    	String[] columnNames2 = { "number", "name", "status","Command" };
			  	    String[][] tableData2 = {{"1",     "avi",     "done"    , "11234" },
				                                {"2",   "dos",     "done" , "11234"    },
				                                {"3",  "tres",    "done"    , "11234" },
				                                { "4", "cuatro",  "done", "11234"},
				                                { "5",   "cinco",   "done" , "11234"},
				                                { "6",    "seis",    "done"   , "11234" },
				                                { "7",   "siete",   "done" , "11234" } ,
				                                { "8",   "siete",   "done"  , "11234"},
				                                { "9",   "siete",   "done"  , "11234"},
				                                { "10",   "siete",   "done"  , "11234"},
				                                { "11",   "siete",   "done"  , "11234"},
				                                { "12",   "siete",   "done"  , "11234"},
				                                { "13",   "siete",   "done"  , "11234"},
				                                { "14",   "siete",   "done"  , "11234"},
				                                { "7",   "siete",   "done" , "11234" } ,
				                                { "8",   "siete",   "done"  , "11234"},
				                                { "9",   "siete",   "done"  , "11234"},
				                                { "10",   "siete",   "done"  , "11234"},
				                                { "11",   "siete",   "done"  , "11234"},
				                                { "12",   "siete",   "done"  , "11234"},
				                                { "13",   "siete",   "done"  , "11234"},
				                                { "14",   "siete",   "done"  , "11234"},
				                                { "7",   "siete",   "done" , "11234" } ,
				                                { "8",   "siete",   "done"  , "11234"},
				                                { "9",   "siete",   "done"  , "11234"},
				                                { "10",   "siete",   "done"  , "11234"},
				                                { "11",   "siete",   "done"  , "11234"},
				                                { "12",   "siete",   "done"  , "11234"},
				                                { "13",   "siete",   "done"  , "11234"},
				                                { "14",   "siete",   "done"  , "11234"},
				                                { "7",   "siete",   "done" , "11234" } ,
				                                { "8",   "siete",   "done"  , "11234"},
				                                { "9",   "siete",   "done"  , "11234"},
				                                { "10",   "siete",   "done"  , "11234"},
				                                { "11",   "siete",   "done"  , "11234"},
				                                { "12",   "siete",   "done"  , "11234"},
				                                { "13",   "siete",   "done"  , "11234"},
				                                { "14",   "siete",   "done"  , "11234"},
				                                { "15",   "siete",   "done"  , "333333"}};
			  	   // Thread.sleep(5000);
			  	    b.buildTabel(columnNames2, tableData2);
					
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
}
